/*
 * @Author: qianmingtian
 * @Date: 2020-07-04 14:09:25
 * @LastEditors: qianmingtian
 * @LastEditTime: 2020-07-04 17:28:25
 * @FilePath: \qianmingtian.github.io\code\java\com\zhuandshao\FinalTest.java
 */
package com.zhuandshao;

class User {
    public static String GUO_JI = "中国";
    int age;

    public User(int age) {
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

}

public class FinalTest {

    // final int age = 100; // 常量
     int age = 100; // 常量

    static {
        System.out.println("before");
    }

    void test(){
        this.age = 10;
    }

    public static void main(String[] args) {
        
        
        final int i = 100;
        // i = 200; // 编译错误 final修饰的变量不可二次赋值
        User a = new User(90); // a = 0x1234

        a = new User(20); // a = 0x2345
        System.out.println(User.GUO_JI);
        System.out.println(User.GUO_JI);

        final User user = new User(80); // final 修饰的应用，一旦指向一个对象，不能再指向其他对象，但是该对象内部的实例变量是可以被更改的

        user.age = 20;

        user.getAge();

        // user = new User(20);

        // user = null;
        main(10);
    }

    public static void main(int i) {
        System.out.println(i);
    }

    static {
        System.out.println("after");
    }

}/*
  * @Author: qianmingtian
  * 
  * @Date: 2020-07-04 14:09:25
  * 
  * @LastEditors: qianmingtian
  * 
  * @LastEditTime: 2020-07-04 14:09:25
  * 
  * @FilePath: \qianmingtian.github.io\code\java\com\zhuandshao\FinalTest.java
  */
